﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Eudaemon.ProeAssist.WinGUIControls;
using Eudaemon.ProeAssist.Core;
using System.IO;

namespace WinControls
{
    public partial class Form1 : Form
    {
        DriveList dList = new DriveList();
        string currentPath;
        DirectoryWalker walker = new DirectoryWalker();
        FileListView fileList = new FileListView();
        
        public Form1()
        {
            
            InitializeComponent();
            InitDriveList();
            InitFileListView();
        }

        private void InitFileListView()
        {
            fileList.Name = "Test files List";
            fileList.Parent = splitContainer1.Panel2;
            fileList.Dock = DockStyle.Fill;
            fileList.BeginInit();
            fileList.EndInit();

            ListViewItem item1 = new ListViewItem("item1", 0);
            // Place a check mark next to the item.
            item1.SubItems.Add("a");
            item1.SubItems.Add("b");
            item1.SubItems.Add("c");
            item1.SubItems.Add("d");
            //item1.SubItems.Add("e");
            ListViewItem item2 = new ListViewItem("item2", 1);
            item2.SubItems.Add("e");
            item2.SubItems.Add("b");
            item2.SubItems.Add("ffffffffffff");
            item2.SubItems.Add("ggggg");
            item2.SubItems.Add("effc");
            ListViewItem item3 = new ListViewItem("item3", 0);
            // Place a check mark next to the item.
            item3.SubItems.Add("e");
            item3.SubItems.Add("b");
            item3.SubItems.Add("11111");
            item3.SubItems.Add("2");
            item3.SubItems.Add("effa");
            item3.ImageIndex = 2;
            fileList.Items.AddRange(new ListViewItem[] { item1, item2, item3 });

            ImageList imageListSmall = new ImageList();
            string dir = @"E:\CSharpProject\M0002\Src\ProeAssist2\Resource\proeFileType\";
            imageListSmall.Images.Add(Bitmap.FromFile(dir +"Assembly.png"));
            imageListSmall.Images.Add(Bitmap.FromFile(dir + "Diagram.png"));
            imageListSmall.Images.Add(Bitmap.FromFile(dir + "Drawing.png"));
            imageListSmall.Images.Add(Bitmap.FromFile(dir + "Part.png"));
            fileList.SmallImageList = imageListSmall;


        }

        private void InitDriveList()
        {
            dList.Name = "Test Drive List";
            dList.Parent = splitContainer1.Panel1;
            dList.Dock = DockStyle.Fill;
            dList.BeginInit();
            dList.EndInit();
            ToolStripButton btn;
            foreach (ToolStripItem item in dList.Items)
            {
                if (item is ToolStripButton)
                {
                    btn = (ToolStripButton)item;
                    btn.Click += new EventHandler(listBtn_ClickGetPath);   
                }
            }
        }

        void listBtn_ClickGetPath(object sender, EventArgs e)
        {
            if (sender is ToolStripButton)
            {
                ToolStripButton btn = (ToolStripButton)sender;
                currentPath = btn.ToolTipText;
                // Update other controls
                toolStripTextBox1.Text = currentPath;
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
        }

        private void toolStripButton3_Click(object sender, EventArgs e)
        {
            dList.RefreshList();
        }

        private void tsbGo_Click(object sender, EventArgs e)
        {

        }
    }
}